<?php
namespace Service;

class Bank4Element extends Base
{

    public function getDatabase()
    {
        return $this->get(DATABASE_BANK4ELEMENT);
    }

    public function getOneByUnique($unique)
    {
        $database = $this->getDatabase();
        return $database->getOneByField('dry_unique', $unique);
    }

    public function addData($unique, $name, $idCard, $bankCard, $phone, $result, $raw)
    {
        $coreEncrypt = $this->get(CORE_ENCRYPT)->setKey('sensitive');
        $idCard = $coreEncrypt->encrypt($idCard);
        $bankCard = $coreEncrypt->encrypt($bankCard);
        $phone = $coreEncrypt->encrypt($phone);
        $raw = $coreEncrypt->encrypt($raw);
        $now = getDateTime();
        $insert = [
            'dry_unique' => $unique,
            'dry_name' => $name,
            'dry_id_card' => $idCard,
            'dry_bank_card' => $bankCard,
            'dry_phone' => $phone,
            'dry_result' => $result,
            'dry_raw' => $raw,
            'dry_add_time' => $now['date_time']
        ];
        return $this->add($insert);
    }

}